package com.quan.demo.controller;

import com.quan.demo.entity.Student;
import com.quan.demo.service.StudentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author YC
 * @Description 测试模块
 * @date 2021/3/15 8:46
 */
@RestController
@Api(tags = "测试模块")
@RequestMapping("/student")
@Slf4j
public class StudentController {
    /**
     * 记录日志
     */
    private Logger logger = LoggerFactory.getLogger(StudentController.class);

    @Autowired
    private StudentService studentService;


    @ApiOperation(value = "测试增加", notes = "测试增加")
    @PostMapping("/add")
    public void addStudent(@RequestBody Student student) {
        studentService.addStudent(student);
    }

//    @ApiOperation(value = "测试增加", notes = "测试增加")
//    @PostMapping("/add")
//    public void addStudent() {
//        studentService.addStudentCeshi();
//    }

    @ApiOperation(value = "测试删除", notes = "测试删除")
    @DeleteMapping("/del/{id}")
    public void delStudent(@PathVariable Integer id) {
        log.info("我进来了 大家好");
        studentService.delStudent(id);
    }


    @ApiOperation(value = "测试更改", notes = "测试更改")
    @PutMapping("/update")
    public void updateStudent(@RequestBody Student student) {
        studentService.updateStudent(student);
    }


    @ApiOperation(value = "测试查询", notes = "测试查询")
    @GetMapping("/get")
    public List<Student> getStudent() {
        return studentService.getStudent();
    }


    @ApiOperation(value = "测试美元", notes = "测试美元")
    @GetMapping("/ceshidaolao")
    public void ceshidaolao() {
        studentService.createDwbgjl();
    }

    //git
}


